/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package gestionmagasins_aspectj_junit_patterns.model;

import java.util.Date;

/**
 *
 * @author Nathan
 * 
 * Classe client dans l'application
 */
public class Client 
{
    private String nom;
    private String prenom;
    private String adresse;
    private Date dateNaissance;
    private String telephone;
    private String sexe;
    private boolean activate;
    
    /*Contructeur*/
    public Client()
    {
        this.nom = "";
        this.prenom = "";
        this.adresse = "";
        this.dateNaissance = null;
        this.telephone = "";
        this.sexe = "";
        this.activate = true;
    }
    
    public Client(String nom, String prenom, String adresse, Date dateNaissance, String telephone, String sexe) 
    {
        this.nom = nom;
        this.prenom = prenom;
        this.adresse = adresse;
        this.dateNaissance = dateNaissance;
        this.telephone = telephone;
        this.sexe = sexe;
        this.activate = true;
    }

    
    /*Accesseur*/
    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        if (nom != null) 
        {
            this.nom = nom;
        }
        else
        {
            this.nom = "";
        }
    }

    public String getPrenom() {
        return prenom;
    }

    public void setPrenom(String prenom) {
        if (prenom != null)
        {
            this.prenom = prenom;
        }
        else
        {
            this.prenom = "";
        }
    }

    public String getAdresse() {
        return adresse;
    }

    public void setAdresse(String adresse) {
        if (adresse != null) 
        {
            this.adresse = adresse;
        }
        else
        {
            this.adresse = "";
        }
    }

    public Date getDateNaissance() {
        return dateNaissance;
    }

    public void setDateNaissance(Date dateNaissance) {
        this.dateNaissance = dateNaissance;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        if (telephone != null)
        {
            if (telephone.matches("^\\d{10}$")) 
            {
                this.telephone = telephone;    
            }
            else
            {
                this.telephone = "<<Format invalide>>";
            }            
        }
        else
        {
            this.telephone = "";
        }
        
    }

    public String getSexe() {
        return sexe;
    }

    public void setSexe(String sexe) {
        if (sexe != null)
        {
            if (sexe.equals("Masculin") || sexe.equals("Féminin")) 
            {
                this.sexe = sexe;   
            }
            else
            {
                this.sexe = "Masculin";
            }
        }
        else
        {
            this.sexe = "Masculin";
        }                    
    }
    
    public boolean isActivate() {
        return activate;
    }

    public void setActivate(boolean activate) {
        this.activate = activate;
    }

    @Override
    public String toString() 
    {
        if (!prenom.equals("") && !nom.equals(""))
        {
            return prenom + " " + nom;
        }
        else
        {
            return prenom+nom;
        }
    }
    
    
}
